import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { SiteVO, SiteForm, SiteQuery } from './types';

/**
 * 查询橙子建站落地页列表
 * @param query
 * @returns {*}
 */

export const listSite = (query?: SiteQuery): AxiosPromise<SiteVO[]> => {
  return request({
    url: '/oce/third/getToolsSiteList',
    method: 'get',
    params: query
  });
};

/**
 * 同步广告主下的落地页
 * @param query
 */
export const syncSite = (query?: SiteQuery): AxiosPromise<SiteVO[]> => {
  return request({
    url: '/oce/site/syncSite',
    method: 'get',
    params: query
  });
};

/**
 * 查询橙子建站落地页详细
 * @param siteId
 */
export const getSite = (siteId: string | number): AxiosPromise<SiteVO> => {
  return request({
    url: '/oce/site/' + siteId,
    method: 'get'
  });
};

/**
 * 新增橙子建站落地页
 * @param data
 */
export const addSite = (data: SiteForm) => {
  return request({
    url: '/oce/site',
    method: 'post',
    data: data
  });
};

/**
 * 修改橙子建站落地页
 * @param data
 */
export const updateSite = (data: SiteForm) => {
  return request({
    url: '/oce/site',
    method: 'put',
    data: data
  });
};

/**
 * 删除橙子建站落地页
 * @param siteId
 */
export const delSite = (siteId: string | number | Array<string | number>) => {
  return request({
    url: '/oce/site/' + siteId,
    method: 'delete'
  });
};
